﻿using Persistencia;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dlls
{
   public class ServicoDLL
    {
        Context context;

        public ServicoDLL()
        {
            context = new Context();
        }
        public IEnumerable<Servico> List()
        {
            return (from o in context.Servico select o).ToList();
        }

        public void Insert(Servico servico)
        {
            context.Servico.InsertOnSubmit(servico);
            context.SubmitChanges();
        }

        public void Update(int codigo, Servico servico)
        {
            Servico ser = context.Servico.SingleOrDefault(o => o.Codigo == codigo);
            context.SubmitChanges();
        }
        public void Delete(Servico servico)
        {
            context.Servico.DeleteOnSubmit(servico);
            context.SubmitChanges();

        }
        public string getNomePorCodigo(int codigo)
        {
            return context.Servico.SingleOrDefault(e => e.Codigo == codigo).Nome;
        }

    }
}
